package com.lijiajia.cloud.authserver.pojo.mongodb;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;
import java.util.Set;

/**
 * 菜单
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@Document(collection = "menu")
public class Menu {
    public enum Type {
        menu, button
    }

    /**
     * id
     */
    @Id
    @JsonIgnore
    private ObjectId mongodbId;

    /**
     * 菜单id
     */
    private Long id;

    /**
     * 上级id
     */
    private Long parentId;

    /**
     * 名称
     */
    private String name;

    /**
     * 类型
     */
    private Type type;

    /**
     * 权限标识
     */
    private Set<String> authorityIds;

    /**
     * 前端URL
     */
    private String path;

    /**
     * 前端icon
     */
    private String icon;

    /**
     * 排序值
     */
    private Long sorted;

    /**
     * 启用
     */
    private Boolean enabled;

    /**
     * 创建时间
     */
    @CreatedDate
    private LocalDateTime createdAt;
    public static final String CREATED_AT = "created_at";
    /**
     * 最后修改时间
     */
    @LastModifiedDate
    private LocalDateTime lastModifiedAt;
    public static final String LAST_MODIFIED_AT = "last_modified_at";

    public static final String ID = "id";
    public static final String PARENT_ID = "parent_id";
    public static final String NAME = "name";
    public static final String TYPE = "type";
    public static final String AUTHORITY_IDS = "authority_ids";
    public static final String PATH = "path";
    public static final String ICON = "icon";
    public static final String SORTED = "sorted";
    public static final String ENABLED = "enabled";


}
